package com.xunwulian.web.entity;

import com.xunwulian.base.constant.BillStatus;
import com.xunwulian.base.constant.PkgType;
import com.xunwulian.base.entity.BillDetailEntity;
import com.xunwulian.base.util.EnumUtils;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;

import java.lang.reflect.InvocationTargetException;

/**
 * Created by liyankai on 2017/4/2.
 */
public class BillDetailEntityWraper extends BillDetailEntity {

    private String pkgStr;

    private String statusStr;

    public BillDetailEntityWraper() {
    }

    public BillDetailEntityWraper(BillDetailEntity entity) {

        try {
            ConvertUtils.register(new DateConverter(null), java.util.Date.class);

            BeanUtils.copyProperties(this, entity);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        this.statusStr = BillStatus.UNKNOWN.getDesc();
        BillStatus billStatus = EnumUtils.getEnumByType(BillStatus.class, entity.getStatus());
        if (billStatus != null) {
            statusStr = billStatus.getDesc();
        }

        // 用户套餐
        this.pkgStr = PkgType.UNKNOWN.getDesc();
        PkgType pkgType = EnumUtils.getTripEnumByType(PkgType.class, this.getUserPkg());
        if (pkgType != null) {
            pkgStr = pkgType.getDesc();
        }

    }

    public String getPkgStr() {
        return pkgStr;
    }

    public void setPkgStr(String pkgStr) {
        this.pkgStr = pkgStr;
    }

    public String getStatusStr() {
        return statusStr;
    }

    public void setStatusStr(String statusStr) {
        this.statusStr = statusStr;
    }
}
